package com.yimi.yinhepda.adapter.RecycleAdapter;

import android.content.Context;
import android.view.View;

import com.yimi.yinhepda.R;
import com.pda.ym.base.CommonRecycleAdapter;
import com.pda.ym.base.CommonViewHolder;
import com.yimi.yinhepda.db.table.LanHuoTable;

import java.util.List;

/**
 * 揽货扫描适配器
 *
 * @author 000432
 * @date 2018/6/1 0001
 */

public class LanHuoScanAdapter extends CommonRecycleAdapter<LanHuoTable> {

    private Context mContext;
    private CommonViewHolder.onItemCommonClickListener mCommonClickListener;

    public LanHuoScanAdapter(Context context, List<LanHuoTable> dataList, CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, R.layout.adapter_lan_huo_scan_item);
        this.mContext = context;
        this.mCommonClickListener = commonClickListener;
    }

    @Override
    public void bindData(CommonViewHolder holder, LanHuoTable data, int position) {
        holder.setCommonClickListener(mCommonClickListener);
        holder.setText(R.id.tv_waybillNo, String.format("%s", data.getWaybillNo()));
        holder.setText(R.id.tv_jianNum, String.format("%s", data.getQuantity()));
        holder.setText(R.id.tv_scanNum, String.format("%s", data.getChildList() == null ? 0 : data.getChildList().size()));
        View view = holder.itemView;
        if (data.isSelect()) {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.yellow));
        } else if (data.isScan()) {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.green));
        } else {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }
    }
}
